import { Component, OnInit } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {ResultList} from '../result-list';
import {RequestMapping} from '../request.mapping';
import {NzMessageService, NzModalSubject} from 'ng-zorro-antd';

@Component({
  selector: 'app-add-menu-form',
  templateUrl: './add-menu-form.component.html',
  styleUrls: ['./add-menu-form.component.css']
})
export class AddMenuFormComponent implements OnInit {

  menu={name:"",type:"",href:"",sort:"" ,remark:""}
  menuTypes=[]
  constructor(private http:HttpClient, private msg: NzMessageService,public modalSubject:NzModalSubject) { }

  ngOnInit() {
    this.menuTypes = [
      { value: '', label: '基础菜单' },
      { value: '', label: '操作与功能' },
    ];
  }


  onSubmit(){
    this.http.post<ResultList>(RequestMapping.SYSTEM_MENUS, this.menu).toPromise()
      .then(response => {
        if(response.status == 200){
          this.msg.success("添加成功",{nzDuration: 5000});
          this.modalSubject.destroy();
        }
      })
  }

}
